#include "src/memory/memory_manager.h"
#include <stdio.h>

int main() {
    printf("Simple Memory Manager Test\n");
    printf("==========================\n");
    
    // Test initialization
    printf("Initializing memory manager...\n");
    memory_manager_t* mm = mm_init(1024 * 1024); // 1MB
    
    if (!mm) {
        printf("Failed to initialize memory manager\n");
        return 1;
    }
    
    printf("Memory manager initialized successfully\n");
    
    // Test basic allocation
    printf("Testing basic allocation...\n");
    void* ptr = mm_alloc(mm, 1024, MEM_TYPE_PAGE_BUFFER);
    
    if (ptr) {
        printf("Allocation successful: %p\n", ptr);
        
        // Test memory access
        memset(ptr, 0xAA, 1024);
        if (((char*)ptr)[0] == (char)0xAA) {
            printf("Memory access test passed\n");
        } else {
            printf("Memory access test failed\n");
        }
        
        // Free memory
        mm_free(mm, ptr);
        printf("Memory freed\n");
    } else {
        printf("Allocation failed\n");
    }
    
    // Print statistics
    printf("\nMemory manager statistics:\n");
    mm_print_stats(mm);
    
    // Cleanup
    printf("\nCleaning up...\n");
    mm_cleanup(mm);
    printf("Cleanup complete\n");
    
    return 0;
}